<?php
function get_table($team_id)
{
    global $svo, $table, $tools;

    #$data = $svo->readRecordset("select g.stats_game_season, g.stats_game_league from ".$table['Game']." as g where g.stats_game_team_a=".$team_id." || g.stats_game_team_b=".$team_id." order by g.stats_game_time desc limit 1;");
    $data_query = $svo->doSQL("select distinct t.stats_team_id, t.stats_team_season, t.stats_team_league, lg.*, s.* from ".$table['Team']." as t, ".$table['G_Team']." as tg, ".$table['Liga']." as l, ".$table['G_Liga']." as lg, ".$table['Saison']." as s  where t.stats_team_id=".$team_id." && t.stats_team_global_id=tg.stats_team_global_id && l.stats_leagues_id=t.stats_team_league && l.stats_leagues_version=0 && t.stats_team_season=s.stats_season_id && lg.stats_leagues_global_id=l.stats_leagues_global_id order by t.stats_team_league asc;");
    $tabelle = "";
    while ($data = $svo->getRecordset($data_query)) {
        $array = build_table_array($data['stats_team_id'], $data['stats_team_season'], $data['stats_team_league']);
        $t_name = $data['stats_leagues_global_name'];
        $tabelle .= "
        <br>
        <table width=\"480\" border=\"0\" cellpacing=\"0\" cellpadding=\"0\">
            <tr>
                <td colspan=\"12\" align=\"left\" valign=\"top\" class=\"text\"><b>Tabelle</b> - ".$t_name."</td>
            </tr>
                <tr>
                    <td width=\"10\" align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                    <td align=\"left\" valign=\"top\" class=\"text\">&nbsp;</td>
                    <td width=\"10\" align=\"center\" valign=\"top\" class=\"text\"><b>GP</b></td>
                    <td colspan=\"3\" align=\"center\" valign=\"top\" class=\"text\"><b>K&ouml;rbe</b></td>
                    <td align=\"center\" valign=\"top\" class=\"text\"><b>Diff.</b></td>
                    <td colspan=\"3\" align=\"center\" valign=\"top\" class=\"text\"><b>Punkte</b></td>
                    <td align=\"center\" valign=\"top\" class=\"text\"><b>Off.</b></td>
                    <td align=\"center\" valign=\"top\" class=\"text\"><b>Def.</b></td>
                </tr>
        ";
        $i = 0;
        foreach ($array as $row) {
            $i++;
            $star = "";

            if (eregi("Red Eagles Rathenow", $row['team_name'])) $b = array ("<b>", "</b>");
            else $b = array ("","");

            for ($x=0; $x<$row['star']; $x++) $star .= "*";
            if (($row['Games']-$row['star']-$row['star_against']) > 0) $off = number_format(round(($row['P_+']-$row['star_against'])/($row['Games']-$row['star']-$row['star_against']),1),1);
            else $off = 0;
            if (($row['Games']-$row['star']-$row['star_against']) > 0) $def = number_format(round(($row['P_-']-$row['star'])/($row['Games']-$row['star']-$row['star_against']),1),1);
            else $def = 0;

            $tabelle .= "
                <tr>
                    <td align=\"center\" valign=\"top\" class=\"text\">".$b[0]."".$i.".&nbsp;".$b[1]."</td>
                    <td align=\"left\" valign=\"top\" class=\"text\">".$b[0]."".$row['team_name']." ".$row['team_index'].$star."".$b[1]."</td>
                    <td align=\"center\" valign=\"top\" class=\"text\">".$b[0]."".$row['Games']."".$b[1]."</td>
                    <td align=\"right\" valign=\"top\" class=\"text\">".$b[0]."".($row['P_+']-$row['star_against'])."".$b[1]."</td>
                    <td align=\"center\" valign=\"top\" class=\"text\">".$b[0].":".$b[1]."</td>
                    <td align=\"left\" valign=\"top\" class=\"text\">".$b[0]."".($row['P_-']-$row['star'])."".$b[1]."</td>
                    <td align=\"center\" valign=\"top\" class=\"text\">".$b[0]."".($row['P_+']-$row['P_-'])."".$b[1]."</td>
                    <td align=\"right\" valign=\"top\" class=\"text\">".$b[0]."".($row['Games_won']*2)."".$b[1]."</td>
                    <td align=\"center\" valign=\"top\" class=\"text\">".$b[0].":".$b[1]."</td>
                    <td align=\"left\" valign=\"top\" class=\"text\">".$b[0]."".($row['Games_lost']*2)."".$b[1]."</td>
                    <td align=\"center\" valign=\"top\" class=\"text\">".$b[0]."".$off."".$b[1]."</td>
                    <td align=\"center\" valign=\"top\" class=\"text\">".$b[0]."".$def."".$b[1]."</td>
                </tr>
            ";
        }
    $tabelle .= "
            </table>";
    }
    $tabelle .= "
        <table width=\"480\" border=\"0\" cellpacing=\"0\" cellpadding=\"0\">
            <tr>
                <td colspan=\"12\" align=\"center\" valign=\"top\" class=\"hint\">&nbsp;</td>
            </tr>
            <tr>
                <td colspan=\"12\" align=\"left\" valign=\"top\" class=\"hint\"><b>GP</b>-absolvierte Spiele, <b>Off</b>-Punkteschnitt offensiv, <b>Def</b>-Punkteschnitt defensiv</td>
            </tr>
        </table>
        ";
    return $tabelle;
}

function build_table_array($t_id, $season, $league)
{
    global $svo, $table, $tools;
    $array = "";

    $get_teams_sql = "select t.stats_team_id, g.stats_team_global_name, g.stats_team_global_index, g.stats_team_global_id from ".$table['Team']." as t, ".$table['G_Team']." as g where t.stats_team_league=".$league." && t.stats_team_season=".$season." && t.stats_team_global_id=g.stats_team_global_id;";
    $get_teams     = $svo->doSQL($get_teams_sql);
    $i = 0;
    while ($team_id = $svo->getRecordset($get_teams)) {
        $team_data = $svo->doSQL("select stats_game_team_a, stats_game_team_b, stats_game_erg_a, stats_game_erg_b, stats_game_winner from ".$table['Game']." where (stats_game_team_a=".$team_id['stats_team_id']." || stats_game_team_b=".$team_id['stats_team_id'].") && stats_game_league=".$league." && stats_game_season=".$season." && stats_game_winner is not null;");
        $count_games = $svo->countRows($team_data);
        $array[$i]["season"]       = $season;
        $array[$i]["league"]       = $league;
        $array[$i]["team_id"]      = $team_id['stats_team_id'];
        $array[$i]["team_name"]    = $team_id['stats_team_global_name'];
        $array[$i]["team_index"]   = $team_id['stats_team_global_index'];
        $array[$i]["Games"]        = $count_games;
        $array[$i]["P_+"]          = 0;
        $array[$i]["P_-"]          = 0;
        $array[$i]["Games_won"]    = 0;
        $array[$i]["Games_lost"]   = 0;
        $array[$i]["star"]         = 0;
        $array[$i]["star_against"] = 0;

        while ($team = $svo->getRecordset($team_data)) {
            if ($team['stats_game_team_a'] == $team_id['stats_team_id']) {
                $array[$i]["P_+"] = $array[$i]["P_+"] + $team['stats_game_erg_a'];
                $array[$i]["P_-"] = $array[$i]["P_-"] + $team['stats_game_erg_b'];
                if ($team['stats_game_winner']) $array[$i]["Games_lost"]++;
                else $array[$i]["Games_won"]++;
                if (($team['stats_game_erg_a'] > $team['stats_game_erg_b'] && $team['stats_game_winner']) || (!$team['stats_game_erg_a'] && $team['stats_game_erg_b'] && $team['stats_game_team_a'] == $team_id['stats_team_id']) ) $array[$i]["star"]++;
                if (($team['stats_game_erg_a'] < $team['stats_game_erg_b'] && !$team['stats_game_winner']) || ($team['stats_game_erg_a'] && !$team['stats_game_erg_b'] && $team['stats_game_team_a'] == $team_id['stats_team_id']) ) $array[$i]["star_against"]++;
            } else {
                $array[$i]["P_+"] = $array[$i]["P_+"] + $team['stats_game_erg_b'];
                $array[$i]["P_-"] = $array[$i]["P_-"] + $team['stats_game_erg_a'];
                if ($team['stats_game_winner']) $array[$i]["Games_won"]++;
                else $array[$i]["Games_lost"]++;
                if (($team['stats_game_erg_a'] < $team['stats_game_erg_b'] && !$team['stats_game_winner']) || ($team['stats_game_erg_a'] && !$team['stats_game_erg_b'] && $team['stats_game_team_b'] == $team_id['stats_team_id']) ) $array[$i]["star"]++;
                if (($team['stats_game_erg_a'] > $team['stats_game_erg_b'] && $team['stats_game_winner']) || (!$team['stats_game_erg_a'] && $team['stats_game_erg_b'] && $team['stats_game_team_b'] == $team_id['stats_team_id']) ) $array[$i]["star_against"]++;
            }
        }
        $i++;
    }

    $array = sort_array($array);
    return $array;
}

function sort_array($tabelle)
{
    $tabelle_text = "";
    for ($m=0;$m<count($tabelle);$m++) {
        for ($i=0;$i<count($tabelle)-1;$i++) {
            if ($tabelle[$i]['Games_won'] < $tabelle[$i+1]['Games_won']) {
                $tabellex[0]   = $tabelle[$i];
                $tabelle[$i]   = $tabelle[$i+1];
                $tabelle[$i+1] = $tabellex[0];
            } elseif ($tabelle[$i]['Games_won'] == $tabelle[$i+1]['Games_won']) {
                if ($tabelle[$i]['Games_lost'] > $tabelle[$i+1]['Games_lost']) {
                    $tabellex[0]   = $tabelle[$i];
                    $tabelle[$i]   = $tabelle[$i+1];
                    $tabelle[$i+1] = $tabellex[0];
                } elseif ($tabelle[$i]['Games_lost'] == $tabelle[$i+1]['Games_lost']) {
                    if ($tabelle[$i]['star'] > $tabelle[$i+1]['star']) {
                        $tabellex[0]   = $tabelle[$i];
                        $tabelle[$i]   = $tabelle[$i+1];
                        $tabelle[$i+1] = $tabellex[0];
                    } elseif ($tabelle[$i]['star'] == $tabelle[$i+1]['star']) {
                        if (($tabelle[$i]['P_+']-$tabelle[$i]['P_-']) < ($tabelle[$i+1]['P_+']-$tabelle[$i+1]['P_-'])) {
                            $tabellex[0]   = $tabelle[$i];
                            $tabelle[$i]   = $tabelle[$i+1];
                            $tabelle[$i+1] = $tabellex[0];
                        }
                    }
                }
            }
        }
    }

    for ($c=0; $c<count($tabelle);$c++) {
        for ($n=0; $n<count($tabelle)-1;$n++) {
            if ($tabelle[$n]['Games_won'] == $tabelle[$n+1]['Games_won'] && $tabelle[$n]['Games_lost'] == $tabelle[$n+1]['Games_lost'] && $tabelle[$n]['star'] == $tabelle[$n+1]['star']) {
                $direct = direct_comparison($tabelle[$n], $tabelle[$n+1]);
                if ($direct) {
                    $tabellex[0]   = $tabelle[$n];
                    $tabelle[$n]   = $tabelle[$n+1];
                    $tabelle[$n+1] = $tabellex[0];
                }
            }
        }
    }

    return $tabelle;
}

function direct_comparison($team_id_1, $team_id_2)
{
    global $svo, $table;

    $team_data = $svo->doSQL("select stats_game_team_a, stats_game_team_b, stats_game_erg_a, stats_game_erg_b, stats_game_winner from ".$table['Game']." where (stats_game_team_a=".$team_id_1['team_id']." && stats_game_team_b=".$team_id_2['team_id'].") || (stats_game_team_a=".$team_id_2['team_id']." && stats_game_team_b=".$team_id_1['team_id'].") && stats_game_league=".$team_id_1['league']." && stats_game_season=".$team_id_1['season']." && stats_game_erg_a>0 && stats_game_erg_b>0;");
    $count = $svo->countRows($team_data);

    if ($count > 0) {
        $i = 0;
        $winner_team1 = 0;
        $winner_team2 = 0;
        $points_team1 = 0;
        $points_team2 = 0;
        while ($row = $svo->getRecordset($team_data)) {
            if ($row['stats_game_team_a'] == $team_id_1['team_id']) $points_team1 = $points_team1 + $row['stats_game_erg_a'];
            else $points_team2 = $points_team2 + $row['stats_game_erg_a'];
            if ($row['stats_game_team_b'] == $team_id_1['team_id']) $points_team1 = $points_team1 + $row['stats_game_erg_b'];
            else $points_team2 = $points_team2 + $row['stats_game_erg_b'];
            if ($row['stats_game_team_a'] == $team_id_1['team_id'] && !$row['stats_game_winner']) $winner_team1++;
            if ($row['stats_game_team_a'] == $team_id_1['team_id'] && $row['stats_game_winner']) $winner_team2++;
            if ($row['stats_game_team_a'] == $team_id_2['team_id'] && !$row['stats_game_winner']) $winner_team2++;
            if ($row['stats_game_team_a'] == $team_id_2['team_id'] && $row['stats_game_winner']) $winner_team1++;
            $i++;
        }
        if ($winner_team1 > $winner_team2)  $check = 0;
        if ($winner_team1 == $winner_team2) {
            if ($points_team1 > $points_team2) {
                $check = 0;
            } else $check = 1;
            #echo $team_id_1['team_name']."(".$winner_team1."/".$points_team1.")- ".$team_id_2['team_name']."(".$winner_team2."/".$points_team2.") -> ".$check."<br>";
        }
        if ($winner_team1 < $winner_team2)  $check = 1;
    } else $check = 0;
    return $check;
}

function get_team_playerstats($team_id, $game_id)
{
    global $svo, $tools, $table;

    $team_data = $svo->readRecordset("select t.*, g.* from ".$table['Team']." as t, ".$table['G_Team']." as g where t.stats_team_id=".$team_id." && g.stats_team_global_id=t.stats_team_global_id;");

    $i = 0;
    if (empty($game_id)) $player_data = $svo->doSQL("select distinct s.stats_game_stats_player_id, p.*, g.stats_player_global_name, g.stats_player_global_vname, g.stats_player_global_position from ".$table['Stats']." as s, ".$table['Player']." as p, ".$table['G_Player']." as g where s.stats_game_stats_team_id=".$team_id." && p.stats_player_id=s.stats_game_stats_player_id && p.stats_player_id_global=g.stats_player_global_id order by g.stats_player_global_name, g.stats_player_global_vname asc;");
    else $player_data = $svo->doSQL("select distinct s.stats_game_stats_player_id, p.*, g.stats_player_global_name, g.stats_player_global_vname, g.stats_player_global_position from ".$table['Stats']." as s, ".$table['Player']." as p, ".$table['G_Player']." as g where s.stats_game_stats_team_id=".$team_id." && p.stats_player_id=s.stats_game_stats_player_id && p.stats_player_id_global=g.stats_player_global_id && stats_game_stats_game_id=".$game_id." order by g.stats_player_global_name, g.stats_player_global_vname asc;");

#    $tabelle = "<table border=1>";

    while ($player_id = $svo->getRecordset($player_data)) {
        if (empty($game_id)) $player_games = $svo->doSQL("select * from ".$table['Stats']." where stats_game_stats_team_id=".$team_id." && stats_game_stats_player_id=".$player_id['stats_game_stats_player_id']." order by stats_game_stats_game_id asc;");
        else $player_games = $svo->doSQL("select * from ".$table['Stats']." where stats_game_stats_team_id=".$team_id." && stats_game_stats_game_id=".$game_id." && stats_game_stats_player_id=".$player_id['stats_game_stats_player_id'].";");

        $m = 0;
        $array[$i]['global_id'] = $player_id['stats_player_id_global'];
        $array[$i]['id']     = $player_id['stats_game_stats_player_id'];
        $array[$i]['name']   = $player_id['stats_player_global_name'].", ".$player_id['stats_player_global_vname'];
        $array[$i]['pos']    = $player_id['stats_player_global_position'];

        while ($game_data = $svo->getRecordset($player_games)) {
            $array[$i]['stats'][$m]['full_stats'] = check_full_stats($game_data['stats_game_stats_team_id'], $game_data['stats_game_stats_game_id']);
            $array[$i]['stats'][$m]['2pm']    = $game_data['stats_game_stats_2pm'];
            $array[$i]['stats'][$m]['2pa']    = $game_data['stats_game_stats_2pa'];
            $array[$i]['stats'][$m]['3pm']    = $game_data['stats_game_stats_3pm'];
            $array[$i]['stats'][$m]['3pa']    = $game_data['stats_game_stats_3pa'];
            $array[$i]['stats'][$m]['ftm']    = $game_data['stats_game_stats_ftm'];
            $array[$i]['stats'][$m]['fta']    = $game_data['stats_game_stats_fta'];
            $array[$i]['stats'][$m]['roff']   = $game_data['stats_game_stats_roff'];
            $array[$i]['stats'][$m]['rtot']   = $game_data['stats_game_stats_rtot'];
            $array[$i]['stats'][$m]['ass']    = $game_data['stats_game_stats_ass'];
            $array[$i]['stats'][$m]['pf']     = $game_data['stats_game_stats_pf'];
            $array[$i]['stats'][$m]['to']     = $game_data['stats_game_stats_to'];
            $array[$i]['stats'][$m]['stl']    = $game_data['stats_game_stats_stl'];
            $array[$i]['stats'][$m]['blk']    = $game_data['stats_game_stats_blk'];
            $array[$i]['stats'][$m]['points'] = $game_data['stats_game_stats_points'];
/*            $tabelle .= "
            <tr>
                <td>".$array[$i]['name']."</td>
                <td>".$array[$i]['stats'][$m]['full_stats']."</td>
                <td>".$array[$i]['stats'][$m]['2pm']."</td>
                <td>".$array[$i]['stats'][$m]['2pa']."</td>
                <td>".$array[$i]['stats'][$m]['3pm']."</td>
                <td>".$array[$i]['stats'][$m]['3pa']."</td>
            </tr>
            ";
*/            $m++;
        }
        $i++;
    }
#    $tabelle .= "</table>";

    $inner_table = output_table_player($array, $team_id);
    $tabelle = "
    <table width=\"500\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
         	<tr>
         		<td valign=\"top\" align=\"center\" colspan=\"2\"><img src=\"standard/spacer.gif\" width=\"10\" height=\"20\" border=\"0\" alt=\"\"></td>
         	</tr>
         	<tr>
         		<td width=\"20\" valign=\"top\" align=\"left\"><img src=\"standard/spacer.gif\" width=\"20\" height=\"1\" border=\"0\" alt=\"\"></td>
         		<td valign=\"top\" align=\"left\">".$inner_table."</td>
     	    </tr>
    </table>
    ";

    return $tabelle;
}

function game_data($team_id, $game_id)
{
    global $svo, $tools, $table;

    $game = $svo->readRecordset("select * from ".$table['Game']." where stats_game_id=".$game_id.";");

    if ($team_id == $game['stats_game_team_b']) {
        $opp = $svo->readRecordset("select g.stats_team_global_name, g.stats_team_global_short, g.stats_team_global_index from ".$table['G_Team']." as g, ".$table['Team']." as t where t.stats_team_id=".$game['stats_game_team_a']." && t.stats_team_global_id=g.stats_team_global_id;");
        $opponent['short']  = $opp['stats_team_global_short'];
        $opponent['name']   = $opp['stats_team_global_name'];
        $opponent['index']  = $opp['stats_team_global_index'];
        $opponent['points'] = $game['stats_game_erg_a'];
    } else {
        $opp = $svo->readRecordset("select g.stats_team_global_name, g.stats_team_global_short, g.stats_team_global_index from ".$table['G_Team']." as g, ".$table['Team']." as t where t.stats_team_id=".$game['stats_game_team_b']." && t.stats_team_global_id=g.stats_team_global_id;");
        $opponent['short']  = $opp['stats_team_global_short'];
        $opponent['name']   = $opp['stats_team_global_name'];
        $opponent['index']  = $opp['stats_team_global_index'];
        $opponent['points'] = $game['stats_game_erg_b'];
    }
    $opponent['full_data'] = $game;
    return $opponent;
}

function check_full_stats($team_id, $game_id)
{
    global $svo, $tools, $table;

    $summe_pa = $svo->readRecordset("select sum(stats_game_stats_2pa), sum(stats_game_stats_3pa) from ".$table['Stats']." where stats_game_stats_game_id=".$game_id." && stats_game_stats_team_id=".$team_id.";");
    if ($summe_pa[0] > 0 || $summe_pa[1] > 0) $check = 1;
    else $check = 0;
    return $check;
}

function get_team_gamestats($team_id, $player_id)
{
    global $svo, $tools, $table;

    $team_data = $svo->readRecordset("select t.*, g.* from ".$table['Team']." as t, ".$table['G_Team']." as g where t.stats_team_id=".$team_id." && g.stats_team_global_id=t.stats_team_global_id;");

    $i = 0;
    if (empty($player_id)) $game = $svo->doSQL("select distinct s.stats_game_stats_game_id, t.* from ".$table['Stats']." as s, ".$table['Team']." as t where s.stats_game_stats_team_id=".$team_id." && t.stats_team_id=s.stats_game_stats_team_id order by s.stats_game_stats_game_id asc;");
    else $game = $svo->doSQL("select distinct s.stats_game_stats_game_id, t.* from ".$table['Stats']." as s, ".$table['Team']." as t where s.stats_game_stats_team_id=".$team_id." && t.stats_team_id=s.stats_game_stats_team_id && s.stats_game_stats_player_id=".$player_id." order by s.stats_game_stats_game_id asc;");

    while ($game_ids = $svo->getRecordset($game)) {
        if (empty($player_id)) $game_stats = $svo->doSQL("select * from ".$table['Stats']." where stats_game_stats_game_id=".$game_ids['stats_game_stats_game_id']." && stats_game_stats_team_id=".$team_id.";");
        else $game_stats = $svo->doSQL("select * from ".$table['Stats']." where stats_game_stats_game_id=".$game_ids['stats_game_stats_game_id']." && stats_game_stats_player_id=".$player_id." && stats_game_stats_team_id=".$team_id.";");
        $opp = game_data($team_id, $game_ids['stats_game_stats_game_id']);
        $array[$i]['id']         = $game_ids['stats_game_stats_game_id'];
        $array[$i]['name']       = $opp['short']." ".$opp['index'];
        $array[$i]['full_stats'] = check_full_stats($team_id, $game_ids['stats_game_stats_game_id']);
        $array[$i]['2pm']        = 0;
        $array[$i]['2pa']        = 0;
        $array[$i]['3pm']        = 0;
        $array[$i]['3pa']        = 0;
        $array[$i]['ftm']        = 0;
        $array[$i]['fta']        = 0;
        $array[$i]['roff']       = 0;
        $array[$i]['rtot']       = 0;
        $array[$i]['ass']        = 0;
        $array[$i]['pf']         = 0;
        $array[$i]['to']         = 0;
        $array[$i]['stl']        = 0;
        $array[$i]['blk']        = 0;
        $array[$i]['points']     = 0;

        while ($game_data = $svo->getRecordset($game_stats)) {
            $array[$i]['2pm']    = $array[$i]['2pm'] + $game_data['stats_game_stats_2pm'];
            $array[$i]['2pa']    = $array[$i]['2pa'] + $game_data['stats_game_stats_2pa'];
            $array[$i]['3pm']    = $array[$i]['3pm'] + $game_data['stats_game_stats_3pm'];
            $array[$i]['3pa']    = $array[$i]['3pa'] + $game_data['stats_game_stats_3pa'];
            $array[$i]['ftm']    = $array[$i]['ftm'] + $game_data['stats_game_stats_ftm'];
            $array[$i]['fta']    = $array[$i]['fta'] + $game_data['stats_game_stats_fta'];
            $array[$i]['roff']   = $array[$i]['roff'] + $game_data['stats_game_stats_roff'];
            $array[$i]['rtot']   = $array[$i]['rtot'] + $game_data['stats_game_stats_rtot'];
            $array[$i]['ass']    = $array[$i]['ass'] + $game_data['stats_game_stats_ass'];
            $array[$i]['pf']     = $array[$i]['pf'] + $game_data['stats_game_stats_pf'];
            $array[$i]['to']     = $array[$i]['to'] + $game_data['stats_game_stats_to'];
            $array[$i]['stl']    = $array[$i]['stl'] + $game_data['stats_game_stats_stl'];
            $array[$i]['blk']    = $array[$i]['blk'] + $game_data['stats_game_stats_blk'];
            $array[$i]['points'] = $array[$i]['points'] + $game_data['stats_game_stats_points'];
        }

        $i++;
    }

    $inner_table = output_table_games($array, $team_id);
    $tabelle = "
    <table width=\"480\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
         	<tr>
         		<td valign=\"top\" align=\"center\" colspan=\"2\"><img src=\"standard/spacer.gif\" width=\"10\" height=\"20\" border=\"0\" alt=\"\"></td>
         	</tr>
         	<tr>
         		<td valign=\"top\" align=\"left\">".$inner_table."</td>
     	    </tr>
    </table>
    ";
    return $tabelle;
}

function output_table_player ($array, $team_id)
{
      $full_comp_pm2   = 0;
      $full_comp_pa2   = 0;
      $full_comp_pm3   = 0;
      $full_comp_pa3   = 0;
      $full_comp_ftm    = 0;
      $full_comp_fta    = 0;
      $full_comp_roff   = 0;
      $full_comp_rtot   = 0;
      $full_comp_ass    = 0;
      $full_comp_pf     = 0;
      $full_comp_to     = 0;
      $full_comp_stl    = 0;
      $full_comp_blk    = 0;
      $full_comp_points = 0;
      $comp_pm2    = 0;
      $comp_pa2    = 0;
      $comp_pm3    = 0;
      $comp_pa3    = 0;
      $comp_ftm    = 0;
      $comp_fta    = 0;
      $comp_pf     = 0;
      $comp_points = 0;

    $tabelle = "
 			    <table width=\"480\" style=\"border: solid 1px #820400\" cellpadding=\"2\" cellspacing=\"0\">
                    <tr>
         				<td valign=\"top\" class=\"text\" colspan=\"16\" align=\"left\"><b>Spielerstatistiken</b></td>
     				</tr>
                    <tr>
                        <td align=\"left\" valign=\"top\" class=\"text\"><b>Name</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>Pos.</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>GP</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>2PM</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>2PA</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>3PM</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>3PA</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>FTM</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>FTA</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>REB<br>OFF</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>REB<br>TOT</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>ASS</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>PF</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>TO</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>STL</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>BLK</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>PTS</b></td>
                    </tr>
      ";

  for($m=0;$m<count($array);$m++) {
      if ($m%2) $bgcolor = "#cccccc";
      else $bgcolor = "#ffffff";

      $full_games = 0;
      $full_pm2   = 0;
      $full_pa2   = 0;
      $full_pm3   = 0;
      $full_pa3   = 0;
      $full_ftm    = 0;
      $full_fta    = 0;
      $full_roff   = 0;
      $full_rtot   = 0;
      $full_ass    = 0;
      $full_pf     = 0;
      $full_to     = 0;
      $full_stl    = 0;
      $full_blk    = 0;
      $full_points = 0;
      $games      = 0;
      $pm2    = 0;
      $pa2    = 0;
      $pm3    = 0;
      $pa3    = 0;
      $ftm    = 0;
      $fta    = 0;
      $pf     = 0;
      $points = 0;


      foreach($array[$m]['stats'] as $row) {
        if ($row['full_stats']) {
            $full_pm2    = $full_pm2 + $row['2pm'];
            $full_pa2    = $full_pa2 + $row['2pa'];
            $full_pm3    = $full_pm3 + $row['3pm'];
            $full_pa3    = $full_pa3 + $row['3pa'];
            $full_ftm    = $full_ftm + $row['ftm'];
            $full_fta    = $full_fta + $row['fta'];
            $full_roff   = $full_roff + $row['roff'];
            $full_rtot   = $full_rtot + $row['rtot'];
            $full_ass    = $full_ass + $row['ass'];
            $full_pf     = $full_pf + $row['pf'];
            $full_to     = $full_to + $row['to'];
            $full_stl    = $full_stl + $row['stl'];
            $full_blk    = $full_blk + $row['blk'];
            $full_points = $full_points + $row['points'];
            $full_games++;
            $full_comp_pm2    = $full_comp_pm2 + $row['2pm'];
            $full_comp_pa2    = $full_comp_pa2 + $row['2pa'];
            $full_comp_pm3    = $full_comp_pm3 + $row['3pm'];
            $full_comp_pa3    = $full_comp_pa3 + $row['3pa'];
            $full_comp_ftm    = $full_comp_ftm + $row['ftm'];
            $full_comp_fta    = $full_comp_fta + $row['fta'];
            $full_comp_roff   = $full_comp_roff + $row['roff'];
            $full_comp_rtot   = $full_comp_rtot + $row['rtot'];
            $full_comp_ass    = $full_comp_ass + $row['ass'];
            $full_comp_pf     = $full_comp_pf + $row['pf'];
            $full_comp_to     = $full_comp_to + $row['to'];
            $full_comp_stl    = $full_comp_stl + $row['stl'];
            $full_comp_blk    = $full_comp_blk + $row['blk'];
            $full_comp_points = $full_comp_points + $row['points'];
        } else {
            $pm2    = $pm2 + $row['2pm'];
            $pa2    = $pa2 + $row['2pa'];
            $pm3    = $pm3 + $row['3pm'];
            $pa3    = $pa3 + $row['3pa'];
            $ftm    = $ftm + $row['ftm'];
            $fta    = $fta + $row['fta'];
            $pf     = $pf + $row['pf'];
            $points = $points + $row['points'];
            $games++;
            $comp_pm2    = $comp_pm2 + $row['2pm'];
            $comp_pa2    = $comp_pa2 + $row['2pa'];
            $comp_pm3    = $comp_pm3 + $row['3pm'];
            $comp_pa3    = $comp_pa3 + $row['3pa'];
            $comp_ftm    = $comp_ftm + $row['ftm'];
            $comp_fta    = $comp_fta + $row['fta'];
            $comp_pf     = $comp_pf + $row['pf'];
            $comp_points = $comp_points + $row['points'];
        }
      }
      $tabelle .= "
                    <tr bgcolor=\"".$bgcolor."\">
                        <td align=\"left\" valign=\"top\" class=\"text\" nowrap><a href=\"player_stats.php5?team_id=".$team_id."&player_id=".$array[$m]['global_id']."\" class=\"news\" target=\"_self\">".$array[$m]['name']."</a></td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$array[$m]['pos']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$games."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$pm2."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">-</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$pm3."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">-</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$ftm."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$fta."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">-</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">-</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">-</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$pf."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">-</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">-</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">-</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$points."</td>
                    </tr>
      ";
      $tabelle .= "
                    <tr bgcolor=\"".$bgcolor."\">
                        <td align=\"left\" valign=\"top\" class=\"text\" nowrap>&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_games."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_pm2."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_pa2."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_pm3."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_pa3."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_ftm."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_fta."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_roff."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_rtot."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_ass."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_pf."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_to."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_stl."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_blk."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_points."</td>
                    </tr>
      ";
  }

  if ($full_comp_pa2 > 0 ) $perc_2p = ($full_comp_pm2/$full_comp_pa2*100);
  else $perc_2p = 0;
  if ($full_comp_pm3 > 0 ) $perc_3p = ($full_comp_pm3/$full_comp_pa3*100);
  else $perc_3p = 0;
  if (($comp_fta+$full_comp_fta) > 0 ) $perc_ft = (($comp_ftm+$full_comp_ftm)/($comp_fta+$full_comp_fta)*100);
  else $perc_ft = "-";

  $tabelle .= "
                    <tr>
   					    <td valign=\"top\" class=\"text\" colspan=\"16\" align=\"left\">&nbsp;</td>
  			        </tr>
                    <tr bgcolor=\"#cccccc\">
                        <td align=\"left\" valign=\"top\" class=\"text\" nowrap><b>lt. SpBB.</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$comp_pm2."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$comp_pa2."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$comp_pm3."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$comp_pa3."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$comp_ftm."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$comp_fta."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$comp_pf."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$comp_points."</td>
                    </tr>
                    <tr bgcolor=\"#cccccc\">
                        <td align=\"left\" valign=\"top\" class=\"text\" nowrap><b>gescoutet</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_pm2."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_pa2."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_pm3."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_pa3."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_ftm."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_fta."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_roff."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_rtot."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_ass."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_pf."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_to."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_stl."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_blk."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_comp_points."</td>
                    </tr>
                    <tr bgcolor=\"#cccccc\">
                        <td align=\"left\" valign=\"top\" class=\"text\" nowrap><b>Quote</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\" colspan=\"2\">".number_format($perc_2p,1)." %</td>
                        <td align=\"center\" valign=\"top\" class=\"text\" colspan=\"2\">".number_format($perc_3p,1)." %</td>
                        <td align=\"center\" valign=\"top\" class=\"text\" colspan=\"2\">".number_format($perc_ft,1)." %</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                    </tr>
                    <tr>
   					    <td valign=\"top\" class=\"text\" colspan=\"16\" align=\"left\">&nbsp;</td>
  			        </tr>
     			</table>
     			";
    return $tabelle;
}

function output_table_games ($array, $team_id)
{
    global $season_id, $league_id;

    $tabelle = "
 			    <table width=\"480\" style=\"border: solid 1px #820400\" cellpadding=\"2\" cellspacing=\"0\">
                    <tr>
                        <td align=\"left\" valign=\"top\" class=\"text\"><b>Gegner</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>2PM</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>2PA</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>3PM</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>3PA</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>FTM</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>FTA</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>REB<br>OFF</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>REB<br>TOT</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>ASS</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>PF</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>TO</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>STL</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>BLK</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\"><b>PTS</b></td>
                    </tr>
      ";
  $m = 0;
  $full_pm2    = 0;
  $full_pa2    = 0;
  $full_pm3    = 0;
  $full_pa3    = 0;
  $full_ftm    = 0;
  $full_fta    = 0;
  $full_pf     = 0;
  $full_points = 0;
  $pm2    = 0;
  $pa2    = 0;
  $pm3    = 0;
  $pa3    = 0;
  $ftm    = 0;
  $fta    = 0;
  $roff   = 0;
  $rtot   = 0;
  $ass    = 0;
  $pf     = 0;
  $to     = 0;
  $stl    = 0;
  $blk    = 0;
  $points = 0;

  foreach ($array as $row) {
      if ($m%2) $bgcolor = "#cccccc";
      else $bgcolor = "#ffffff";

      if ($row['full_stats']) {
          $full_pm2 = $full_pm2 + $row['2pm'];
          $full_pa2 = $full_pa2 + $row['2pa'];
          $full_pm3 = $full_pm3 + $row['3pm'];
          $full_pa3 = $full_pa3 + $row['3pa'];
          $full_ftm = $full_ftm + $row['ftm'];
          $full_fta = $full_fta + $row['fta'];
          $roff   = $roff + $row['roff'];
          $rtot   = $rtot + $row['rtot'];
          $ass    = $ass + $row['ass'];
          $full_pf = $full_pf + $row['pf'];
          $to     = $to + $row['to'];
          $stl    = $stl + $row['stl'];
          $blk    = $blk + $row['blk'];
          $full_points = $full_points + $row['points'];
      } else {
          $pm2    = $pm2 + $row['2pm'];
          $pa2    = $pa2 + $row['2pa'];
          $pm3    = $pm3 + $row['3pm'];
          $pa3    = $pa3 + $row['3pa'];
          $ftm    = $ftm + $row['ftm'];
          $fta    = $fta + $row['fta'];
          $pf     = $pf + $row['pf'];
          $points = $points + $row['points'];
      }

      $tabelle .= "
                    <tr bgcolor=\"".$bgcolor."\">
                        <td align=\"left\" valign=\"top\" class=\"text\" nowrap><a href=\"game_stats.php5?team_id=".$team_id."&game_id=".$row['id']."\" class=\"news\" target=\"_self\">".$row['name']."</a></td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['2pm']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['2pa']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['3pm']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['3pa']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['ftm']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['fta']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['roff']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['rtot']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['ass']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['pf']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['to']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['stl']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['blk']."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$row['points']."</td>
                    </tr>
      ";
      $m++;
  }
  if ($full_pa2 > 0 ) $perc_2p = ($full_pm2/$full_pa2*100);
  else $perc_2p = 0;
  if ($full_pa3 > 0 ) $perc_3p = ($full_pm3/$full_pa3*100);
  else $perc_3p = 0;
  if (($fta+$full_fta) > 0 ) $perc_ft = (($ftm+$full_ftm)/($fta+$full_fta)*100);
  else $perc_ft = "-";
  $tabelle .= "
                    <tr>
   					    <td valign=\"top\" class=\"text\" colspan=\"16\" align=\"left\">&nbsp;</td>
  			        </tr>
                    <tr bgcolor=\"#cccccc\">
                        <td align=\"left\" valign=\"top\" class=\"text\" nowrap><b>lt. SpBB.</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$pm2."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$pa2."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$pm3."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$pa3."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$ftm."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$fta."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$pf."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$points."</td>
                    </tr>
                    <tr bgcolor=\"#cccccc\">
                        <td align=\"left\" valign=\"top\" class=\"text\" nowrap><b>gescoutet</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_pm2."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_pa2."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_pm3."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_pa3."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_ftm."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_fta."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$roff."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$rtot."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$ass."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_pf."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$to."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$stl."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$blk."</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">".$full_points."</td>
                    </tr>
                    <tr bgcolor=\"#cccccc\">
                        <td align=\"left\" valign=\"top\" class=\"text\" nowrap><b>Quote</b></td>
                        <td align=\"center\" valign=\"top\" class=\"text\" colspan=\"2\">".number_format($perc_2p,1)." %</td>
                        <td align=\"center\" valign=\"top\" class=\"text\" colspan=\"2\">".number_format($perc_3p,1)." %</td>
                        <td align=\"center\" valign=\"top\" class=\"text\" colspan=\"2\">".number_format($perc_ft,1)." %</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                        <td align=\"center\" valign=\"top\" class=\"text\">&nbsp;</td>
                    </tr>
                    <tr>
   					    <td valign=\"top\" class=\"text\" colspan=\"16\" align=\"left\">&nbsp;</td>
  			        </tr>
     			</table>
     			";
    return $tabelle;
}

function get_player_data($p_id)
{
    global $svo, $table, $tools;
    $player = $svo->readRecordset("select * from ".$table['G_Player']." where stats_player_global_id=".$p_id.";");
    return $player;
}
?>
